<!-- 学校信息 -->
<template>
	<view class="schoolInfo">
		<view class="bix-img">
			<image style="width: 750rpx;height: 420rpx;" :src="info.coverUrl" mode="aspectFill"></image>
			<view class="cp_www">
				<view class="st_fl">
					<view class="w1 font14" @click="copy_g">官网</view>
					<view class="w1 font14" @click="copy_y">研网</view>
				</view>
			</view>
		</view>
		<view class="content">
			<view class="content-box">
				<!-- 校名 - 收藏 -->
				<view class="title">
					<text class="bold schoolTitle">{{info.title}}</text>
				</view>
				<!-- 排名 -->
				<view class="baseInfo">
					<view class="k_sign">
						<view class="s_dashed">
							<view class="s_t" style="background-color: #feecb1;	color:#F59A23;;">
								<view class="title-box-style" style="background: #feecb1;">
									<image src="@/static/image/toolbox/title3.png"></image>
									{{info.graduateStudentEducationNationalRankings}}/总{{info.graduateStudentEducationNationalRankingsTotal}}
								</view>
							</view>
							<view class="s_grap" style="background-color: #feecb1;padding:20rpx;">
								<view class="s_num">
									<text class="k_sinum" style="color: #F59A23">研究生竞争力全国排名</text>
								</view>
							</view>
						</view>
						<view class="s_dashed">
							<view class="s_t" style="background-color: rgb(239, 249, 236);color:rgba(25, 204, 165, 0.8);">
								<view class="title-box-style" style="background: #eff9ec;">
									<image src="@/static/image/toolbox/title2.png"></image>
									{{info.graduateStudentEducationAreaRankings}}/总{{info.graduateStudentEducationAreaRankingsTotal}}
								</view>

							</view>
							<view class="s_grap" style="background-color: #eff9ec;padding:20rpx;">
								<view class="s_num">
									<text class="k_sinum" style="color: rgba(25, 204, 165, 0.8)">研究生竞争力本地排名</text>
								</view>
							</view>
						</view>

						<view class="s_dashed">
							<view class="s_t" style="background-color: rgb(216, 241, 255);color:#02A7F0;">
								<view class="title-box-style" style="background: #d8f1ff">
									<image src="@/static/image/toolbox/title1.png"></image>
									{{info.fristClassicSubjectConstructionRankings}}/总{{info.fristClassicSubjectConstructionRankingsTotal}}
								</view>
							</view>

							<view class="s_grap" style="background-color:#d8f1ff;padding:20rpx;">
								<view class="s_num">
									<text class="k_sinum" style="color: #02A7F0">一流学科建设综合竞争力</text>
								</view>
							</view>
						</view>
					</view>

					<view class="k_sign" v-if="info.schoolClassify"
						style="justify-content: flex-start;padding-bottom:0;padding-top: 0;">
						<view class="s_dashed s_dashed-last">
							<view class="s-t-boxs">
								<image src="@/static/image/toolbox/title4.png"></image>
								{{info.schoolClassify}}类{{info.schoolClassifyRankings}}/总{{info.schoolClassifyRankingsTotal}}
							</view>
						</view>
					</view>
				</view>

				<!-- 类型 -->
				<view class="type-box">
					<view class="" v-for="(item,index)  in info.baseSchoolTypes" :key="index">
						<text class="font14" style="color: #969497;">
							{{item.name}}
						</text>
					</view>
				</view>
			</view>


			<view class="content-box">
				<!-- 评价 -->
				<view class="appraise-box">
					{{info.appraise}}
				</view>
				<!-- 优势学科 -->
				<view class="superioritys flex">
					<view class="superiority superiority1 font12" @click="handleClick(1)">
						<view class="superiority-title flex">优势学科</view>
						<view>
							<text class="superiority-num font20">{{majorBeterNum.advantageSubjectCount || 0}}</text>个
							<uni-icons type="forward" size="18" color="#333"></uni-icons>
						</view>
					</view>
					<view class="superiority superiority2 font12" @click="handleClick(2)">
						<view class="superiority-title flex">优势一级学科</view>
						<view>
							<text class="superiority-num font20">{{majorBeterNum.advantageSubjectOneCount || 0}}</text>个
							<uni-icons type="forward" size="18" color="#333"></uni-icons>
						</view>
					</view>
					<view class="superiority superiority3 font12" @click="handleClick(3)">
						<view class="superiority-title flex">优势专业</view>
						<view>
							<text class="superiority-num font20">{{majorBeterNum.advantageMajorCount || 0 }}</text>个
							<uni-icons type="forward" size="18" color="#333"></uni-icons>
						</view>
					</view>
				</view>

				<!-- 学科门类和专业数量 -->
				<view class="echarts-box">
					<view v-for="(item,index) in sujectMajor" :key="index" class="flex echarts-item">
						<view class="flex echarts-item-name">
							<view class="subjectName font14">{{item.subjectName}}</view>
							<view style="width: 80%;">
								<view class="count-width" :style="'width:'+(item.majorCount/maxCount*100)+'%'"></view>
							</view>

						</view>
						<view class="echarts-item-count flex font12" @click="handleClick(5,item.subjectCode,item.subjectName)">
							<text class="font14"> {{item.majorCount}} </text>
							个专业
							<uni-icons type="forward" size="12"></uni-icons>
						</view>
					</view>
				</view>
			</view>

			<!-- 学院设置 -->
			<view class="content-box con news" style="border-top:0;">
				<view class="tip">
					<image src="https://image.alhelp.net/uploads/20231104/5f27e183109a76b8b1897a3a706c6630.png"></image>
					<text>学院设置</text>
				</view>
				<view class="collegeAll">
					<template v-for="(item,index) in collegeBySchool">
						<view class="flex collegeItem" :key="index" v-show="!sollegeALL&&index>10?false:true">
							<view class="font14 title">{{item.title}}</view>
							<view class="font12 flex" style="align-items: center" @click="handleClick(4,item.collegeCode,item.title)">
								<span class="font14 bold majorCount">{{item.majorCount}}</span>
								个专业
								<uni-icons type="forward" size="14"></uni-icons>
							</view>
						</view>
					</template>

					<view class="more" v-if="collegeBySchool.length" @click="showMore(1)">
						<uni-icons v-if="sollegeALL" type="top" size="18" color="#F7DD5E"></uni-icons>
						<uni-icons v-else class="img-transform" type="bottom" size="18" color="#F7DD5E"></uni-icons>
						<text style="color:#F7DD5E">{{sollegeALL?'收起内容':'查看全部'}}</text>
					</view>
				</view>
			</view>

			<view class="content-box con news" style="border-top:0;">
				<view class="tip">
					<image src="https://image.alhelp.net/uploads/20231104/5f27e183109a76b8b1897a3a706c6630.png"></image>
					<text>大学简介</text>
				</view>
				<view class="font14" style="margin-top: 20rpx;color: #969497;text-indent: 2em;">
					<rich-text :class="hideInfo?'hide-info info-txt':'info-txt'" :nodes="info.explains||''"></rich-text>
				</view>
				<view class="more" v-if="info.explains" @click="showMore(2)">
					<uni-icons v-if="!hideInfo" type="top" size="18" color="#F7DD5E"></uni-icons>
					<uni-icons v-else class="img-transform" type="bottom" size="18" color="#F7DD5E"></uni-icons>
					<text style="color:#F7DD5E">{{hideInfo?'查看全部':'收起内容'}}</text>
				</view>
				<image v-if="!info.explains" src="http://cdn.uviewui.com/uview/empty/data.png"></image>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		querySchoolDtail,
		newarticleDetails,
		getAdvantages,
		getYearMajorFirst,
		usercoll,
		getCollectState,
		usercancel,
		getCollegeBySchoolCode,
		groupBySubject
	} from '@/api/toolbox.js';
	import {
		addCollection,
		cancelCollection
	} from '@/api/collection.js' //收藏相关
	export default {
		props: ['code'],
		data() {
			return {
				iStatusBarHeight: 0,
				hideInfo: true,
				sollegeALL: false, //是否查看全部学院设置内容
				triggered: false,
				info: {
					collectState: false,
					intro: ''
				},
				total: 0,
				Data: [], //文章
				static_url: '',
				setcoll: false,
				iscoll: '收藏',
				showg: false,
				colldata: '',
				pages: 1,
				queryDetail: { //查询学校详情参数
					majorCode: '',
					collegeCode: ''
				},
				isCollect: '',
				yearOptions: [],
				majorBeterNum: {},
				collegeBySchool: [],

				sujectMajor: [],
				maxCount: 0,
			}
		},
		methods: {
			getData() {
				new Promise((resolve, reject) => {
					getYearMajorFirst().then((res) => {
						res.data.forEach((item) => {
							this.yearOptions.push({
								dictLabel: item,
								dictValue: item
							});
						})
						uni.setStorageSync('yearS', this.yearOptions[0].dictLabel);
						resolve();
					});
				}).then(() => {
					this.getAdvantages();
					// 查询学校详情
					this.getSchoolDetail();
					// 学院设置
					this.getCollegeBySchoolCode();
					// 学科门类及专业数量
					this.getSujectMajor();
				})
			},
			//查看收藏状态
			getCollectState() {
				getCollectState({
					schoolCode: this.code
				}).then(res => {
					if (res.code === 100000) {
						this.setcoll = res.msg == '未收藏' ? false : true;
						this.iscoll = res.msg == '未收藏' ? '收藏' : '取消收藏';
					}
				})
			},
			// 查询学校专业优势数量
			getAdvantages() {
				getAdvantages({
					"schoolCode": this.code,
					"year": this.yearOptions[0].dictLabel,
				}).then(res => {
					this.majorBeterNum = res.data[0];
				}).catch(err => {

				})
			},
			/**
			 * 优势学科点击事件
			 * @param {Object} type 1、优势学科，2、优势一级学科，3、优势专业，4、学院专业，5、学科专业
			 */
			handleClick(type, code, title) {
				uni.navigateTo({
					url: `/pages/toolbox/chooseMajor/school/components/superiority-course?type=${type}&code=${code}&title=${title}`
				})
			},
			// 获取学校详情
			getSchoolDetail() {
				querySchoolDtail({
					"schoolCode": this.code,
					"code": this.code,
					// "majorCode": this.queryDetail.majorCode,
				}).then(res => {
					res.data.explains = res.data.explains.replace(/<[^>]+>/g, "").trim()
					this.info = res.data
					this.info.collectState = false
				}).catch(err => {

				})
			},

			// 学科门类及专业数量
			getSujectMajor() {
				groupBySubject({
					schoolCode: this.code,
					year: this.yearOptions[0].dictLabel
				}).then((res) => {
					this.sujectMajor = res.data;
					res.data.map((item, index) => {
						if (parseInt(item.majorCount) > parseInt(this.maxCount)) {
							this.maxCount = item.majorCount;
						}
					});
				});

			},
			// 学院设置
			getCollegeBySchoolCode() {
				getCollegeBySchoolCode({
					schoolCode: this.code
				}).then(res => {
					this.collegeBySchool = res.data;
				})
			},
			//获取文章列表
			getAttricleList() {
				if (this.pages == 1) {
					this.Data = [];
				}
				newarticleDetails({
					"code": this.code,
					"page": this.pages,
					"pageSize": "10"
				}).then(res => {
					if (this.pages == 1) {
						this.Data = res.data.list;
						this.total = res.data.tatol;
						return
					}
					this.Data.push.apply(this.Data, res.data.list);
					// this.Data.concat(res.data.list)	
				})
			},

			// 跳转到学校的官网、研招办
			to_school_web(url) {},

			cshowg() {
				this.showg = false;
			},

			fanHui() {
				uni.navigateBack(1)
			},
			/**
			 * @param {Object} type 1、查看学院专业，2、查看学校简介
			 */
			showMore(type) {
				if (type == 2) {
					this.hideInfo = !this.hideInfo
					return
				}
				this.sollegeALL = !this.sollegeALL;
			},

			// 收藏/取消收藏学校
			collect(iscoll) {
				if (iscoll == '取消收藏') {
					//取消收藏
					usercancel({
						code: this.code
					}).then(res => {
						if (res.code === 100000) {
							// this.showg=true;
							this.setcoll = false;
							this.iscoll = '收藏'
						}
					})
				} else {
					//收藏学校
					usercoll({
						code: '', //this.colldata.collegeCode
						schoolCode: this.code
					}).then(res => {
						if (res.code === 100000) {
							this.showg = true;
							this.setcoll = true;
							this.iscoll = '取消收藏'
						}
					});

				}
			},

			// 复制微信号 weChatID
			copy_g() {
				uni.setClipboardData({
					data: this.info.officalUrl,
					success: function() {
						uni.showToast({
							title: '复制成功',
							icon: 'none'
						})
					}
				})

			},
			copy_y() {
				uni.setClipboardData({
					data: this.info.websiteUrl,
					success: function() {
						uni.showToast({
							title: '复制成功',
							icon: 'none'
						})
					}
				})
			},
			handleJump(item, index) {
				// this.$store.commit("ARTICLE", item);
				uni.setStorageSync('article', JSON.stringify(item));
				uni.navigateTo({
					url: `/pages/toolbox/chooseMajor/components/school/dynamicDetails?state=${index}`
				})
				// uni.navigateTo({
				// 	url: "/components/dynamicDetails?state=" + index
				// });
			},
			dichange() {
				uni.showToast({
					icon: 'none',
					title: '订阅成功',

				})
				this.showg = false
			},
			//底部刷新
			onReachBottom() {
				console.log(this.total);
				if (this.Data.length >= this.total) return;
				this.pages++;
				this.getAttricleList();
			}
		}
	}
</script>

<style lang="scss">
	.schoolInfo {
		background: #f2f2f2;
	}

	page {
		background: #f2f2f2;
		// background: #afafaf;
	}

	.superioritys {
		// display: flex;
		align-items: center;
		justify-content: space-around;
		margin-top: 20rpx;

		.superiority {
			width: 140px;
			height: 120rpx;
			color: #333333;
			text-align: center;

			.superiority-title {
				margin-top: 8rpx;
				justify-content: center;
			}

			image {
				width: 10rpx;
				height: 16rpx;
				position: absolute;
				margin-left: 20px;
				margin-top: 10px;
			}

			.superiority-num {}
		}

		.superiority1 {
			background-color: rgba(254, 239, 189, 1);
		}

		.superiority2 {
			background-color: rgba(239, 249, 237, 1);
		}

		.superiority3 {
			background-color: rgba(216, 241, 255, 1);
		}

	}

	.setview {
		/*width: 100vw;*/
		height: 60vh;
	}

	.bix-img {
		position: relative;
	}

	.cp_www {
		position: absolute;
		left: 0;
		right: 0;
		z-index: 66;
		top: 252rpx;
		margin-left: 20rpx;
	}

	.st_fl {
		display: flex;
		align-items: center;
	}

	.popimg {
		margin-top: 50rpx;
	}

	.nwleft {
		margin-left: 20rpx;
	}

	.setflex {
		display: flex;
		align-items: center;
		text-align: left;
	}

	.w1 {
		width: 100rpx;
		padding: 10rpx 20rpx;
		color: #fff;
		background: #000;
		padding: 10rpx 20rpx;
		margin: 20rpx;
		text-align: center;
		border-radius: 30rpx;
		opacity: 0.7;
	}

	.pop_content {
		background-color: #FFFFFF;
		width: 520rpx;
		border-radius: 20rpx;
		padding: 32rpx 48rpx 64rpx 48rpx;
		padding-top: 0;
	}

	// .unlock .con button {
	// 	width: 140rpx;
	// 	height: 60rpx;
	// 	line-height: 60rpx;
	// 	border-radius: 30rpx;
	// 	color: #fff;
	// 	background-color: #fa624b;
	// }

	.swll {
		width: 420rpx !important;
	}

	.coll-sty {
		text-align: center;
	}

	.img-ot image {
		width: 190rpx;
		height: 190rpx;
		margin-top: 40rpx;
	}

	.succ-co {
		font-size: 32rpx;
		color: #FDB78A;
		font-weight: 600;
		margin-top: 50rpx;
	}

	.d-read {
		font-size: 28rpx;
		color: #C4C1C2;
		margin-top: 40rpx;
	}

	.perdo {
		font-size: 28rpx;
		color: #E2E0E1;
	}

	.box-jian {
		position: absolute;
		left: 20rpx;
	}

	.content {
		// width: 710rpx;
		// margin: 20rpx;
		margin-top: -48rpx;
		// border-radius: 30rpx;
		// background-color: #fff;
		box-sizing: border-box;
		// padding: 32rpx;
		z-index: 10;
		position: relative;

		.content-box {
			background-color: #fff;
			margin-bottom: 20rpx;
			padding: 30rpx;
		}

		.content-box:nth-child(1) {
			border-radius: 30rpx;
			border-bottom-left-radius: 0px;
			border-bottom-right-radius: 0px;
			padding: 32rpx;
			// margin: 0px;
		}

		.echarts-box {
			width: 100%;
			margin-top: 30rpx;

			.echarts-item {
				align-items: center;
				justify-content: space-between;
				margin: 20rpx 0;

				.echarts-item-name {
					width: 80%;
					align-items: center;

					.subjectName {
						width: 100rpx;
						text-align: right;
						margin-right: 10rpx;
					}

					.count-width {
						height: 30rpx;
						// width: 100%;
						background-color: rgba(247, 221, 94, 0.6);
					}
				}

				.echarts-item-count {
					width: 180rpx;
					align-items: center;
					justify-content: flex-end;

					// text-align: right;
					text {
						color: #F7DD5E;
						margin-right: 4rpx;
					}
				}
			}

		}

		.title {
			width: 100%;
			display: flex;
			align-items: flex-end;
			justify-content: space-between;
			// padding-bottom: 32rpx;
			// border-bottom: 1px solid #F4F4F4;
		}

		.baseInfo {
			margin-top: 40rpx;
			padding-bottom: 32rpx;
			// border-bottom: 1px solid #F4F4F4;
		}

		.type-box {
			padding: 30rpx 0 10rpx;
			text-align: center;
			font-size: 26rpx;
			letter-spacing: 2px;
			color: #7F7F7F;
			font-weight: 400;
			font-style: normal;

		}

		.appraise-box {
			color: #989699;
			text-align: left;
			font-weight: 400;
			font-style: normal;
			font-size: 26rpx;
			line-height: 40rpx
		}

		.con {
			// margin-top: 30rpx;
			// width: 100%;
		}

		.con text {
			font-size: 26rpx;
			color: #595959;
			line-height: 40rpx;
			text-align: justify;
		}

		.schoolTitle {
			font-weight: 700;
			font-size: 36rpx;
			colot: #333333
		}
	}

	.info-txt {
		color: #989699;
		text-align: left;
		line-height: 40rpx;
	}

	.hide-info {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		overflow: hidden;
	}

	.content .hide text {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		overflow: hidden;
	}

	.content .more {
		display: 100%;
		margin-top: 10rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.content .more image {
		width: 30rpx;
		height: 30rpx;
	}

	.img-transform {
		// transform: rotate(180deg);
	}

	.content .more text {
		font-size: 24rpx;
		color: #e74c3c;
		margin-left: 15rpx;
	}

	.collect {
		/*width: 150rpx;*/
		height: 60rpx;
		border-radius: 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		/*background-color: #f5f5f5;*/
		padding: 0 10rpx;
	}

	.collect text {
		font-size: 28rpx;
		color: #415b76;
	}

	.collect-on {
		/*background-color: #19cca5;*/
		/*padding: 0 24rpx;*/
	}

	.collect-on text {
		color: #000;
	}

	.collect image {
		width: 34rpx;
		height: 34rpx;
		/*margin-left: 10rpx;*/
	}

	.news {
		// width: 100%;
		// margin-top: 30rpx;
		// padding-top: 40rpx;
		border-top: 1px solid #F4F4F4;

		.tip {
			display: flex;
			align-items: center;

			image {
				width: 56rpx;
				height: 56rpx;
			}

			text {
				font-weight: 700;
				font-style: normal;
				font-size: 15px;
				color: #555555;
				margin-left: 15rpx
			}
		}

	}

	// 学院设置
	.collegeAll {
		.collegeItem {
			margin: 20rpx 0;
			// align-items: center;
			justify-content: space-between;
		}

		.title {
			width: 460rpx;
		}

		.majorCount {
			color: #F7DD5E;
		}
	}

	.news navigator {
		width: 100%;
		display: flex;
		margin-top: 40rpx;
	}

	.news navigator .blok {
		display: block;
		width: 7rpx;
		height: 7rpx;
		border-radius: 50%;
		background-color: #83b3ff;
		margin: 21rpx 30rpx 20rpx 8rpx;
	}

	.news navigator .con {
		flex: 1;
		display: flex;
		flex-direction: column;
		margin-top: 0;
	}

	.news navigator .con text {
		font-size: 28rpx;
		color: #595959;
		line-height: 45rpx;
	}

	.news navigator .con text+text {
		font-size: 26rpx;
		color: #bfbfbf;
	}

	.href {
		// position: absolute;
		// left: 25rpx;
		// top: 390rpx;
	}

	.tab_box {
		padding: 8rpx 24rpx;
		border-radius: 28px;
		font-size: 26rpx;
		color: #fff;
		background-color: rgba(0, 0, 0, 0.6);
		margin-right: 20rpx;
	}

	.k_sign {
		display: flex;
		justify-content: center;
		text-align: center;
		font-size: 24rpx;
		/* margin-top: 30rpx; */
		padding-top: 20rpx;
		padding-bottom: 40rpx;
		background-color: #fff;
		align-items: center;
		border-radius: 0 0 50rpx 50rpx;
	}

	.s_dashed {
		background: #fff;
		margin: 0px 10rpx;
		// padding: 20rpx 10rpx;
		min-width: 192rpx;
		width: auto;
		// border: 2rpx dashed #ccc;
	}

	.s_dashed-last {
		margin: 0px 10rpx 0 0;
	}

	.s_t {
		margin-top: 4rpx;
		color: #DDDDDD;
		padding: 10rpx;
		border-radius: 20rpx 20rpx 0 0;
		font-size: 22rpx;
		font-style: italic;
		text-align: left;
	}

	.title-box-triangle {
		// border-width: 0px;
		position: absolute;
		left: 676px;
		top: 701px;
		width: 8px;
		height: 6px;
		display: flex;
		-webkit-transform: rotate(37deg);
		-moz-transform: rotate(37deg);
		-ms-transform: rotate(37deg);
		transform: rotate(37deg);

	}

	.title-box-style {
		padding: 0 10rpx 0 0;
		margin-left: -11px;
		margin-top: -10px;
		height: 46rpx;
		// font-weight: 400;
		font-style: italic;
		font-size: 24rpx;
		// width: 106rpx;
		width: 130rpx;
		min-width: 106rpx;
		border-radius: 30rpx;
		border-top-left-radius: 0px;
		border-bottom-left-radius: 0px;
		line-height: 38rpx;
		// border:none;
		// display: inline-block;
		position: relative;

		image {
			mix-blend-mode: multiply;
			// min-width: 106rpx;
			width: 100%;
			height: 46rpx;
			position: absolute;
		}
	}

	.s-t-boxs {
		color: #fff;
		min-width: 200rpx;
		padding: 0 10rpx 0 0;
		height: 56rpx;
		color: #008080;
		// font-weight: 400;
		// font-style: normal;
		font-size: 28rpx;
		line-height: 48rpx;
		text-align: center;
		border: none;

		display: inline-block;
		position: relative;

		// padding: 0 10rpx;
		image {
			mix-blend-mode: multiply;
			// min-width: 106rpx;
			// min-width: 106rpx;
			// width: auto;
			height: 56rpx;
			width: 100%;
			position: absolute;
		}
	}

	.k_sinum {
		display: inline-flex;
		font-size: 22rpx;
		font-weight: 400;
		// letter-spacing: 2px;
	}
</style>